const Sequelize = require('sequelize')
const sequelize = require('../config/index')
const User = require('./user').User
const TaskList = require('./taskList').TaskList

/**
 * 任务报名列表
 * {id} 报名任务id
 * {uid} 报名的用户id
 * {taskid} 任务id
 */
let Task_enrol_list = sequelize.define('task_enrol_list',{
    id:{
        type:Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment:'id',
    },
    headimgurl:{
        type: Sequelize.TEXT
    },
    nickname:{
        type:Sequelize.TEXT,
        comment: '昵称'
    },
    user_name:{
        type:Sequelize.TEXT,
        comment:'姓名'
    },
    t_uid:{
        type:Sequelize.INTEGER,
        comment:"发布任务的人id"
    },
    name:{
        type:Sequelize.STRING,
        defaultValue:'',
        comment:'任务名称',
    },
    demand:{
        type:Sequelize.STRING,
        defaultValue:'无',
        comment:'任务要求',
    },
    describe:{
        type:Sequelize.STRING,
        defaultValue:'无',
        comment:'任务描述',
    },
    time:{
        type:Sequelize.STRING,
        defaultValue:'无',
        comment:'任务周期',
    },
    price:{
        type:Sequelize.INTEGER,
        defaultValue:0,
        comment:'任务定价',
    },
    links1:{
        type:Sequelize.STRING,
        defaultValue:null,
        comment:'参考链接1',
    },
    links2:{
        type:Sequelize.STRING,
        defaultValue:null,
        comment:'参考链接2',
    },
    img_url1:{
        type:Sequelize.TEXT,
        defaultValue:0,
        comment:'参考图片1',
    },
    img_url2:{
        type:Sequelize.TEXT,
        defaultValue:0,
        comment:'参考图片2',
    },
    address:{
        type:Sequelize.STRING,
        defaultValue:0,
        comment:'地址',
    },
    sour:{
        type:Sequelize.STRING,
        defaultValue:'个人',
        comment:'任务源 个人或者企业',
    },
    type:{
        type:Sequelize.STRING,
        defaultValue:0,
        comment:'任务类型',
    },
    isDel:{
        type:Sequelize.STRING,
        defaultValue:0,
        comment:'是否已删除'
    },
    isCheck:{
        type:Sequelize.INTEGER,
        defaultValue:0,
        comment:"对方已确认,0 未确认 1 已确认"
    }

},{

    freezeTableName: true,
},{comment:'报名列表'})
Task_enrol_list.belongsTo(User,{foreignKey: "uid"});
Task_enrol_list.belongsTo(TaskList,{foreignKey: "taskid"});
// Skill.belongsToMany(User, {through : 'userSkill'});
//这会创建一个新模型UserProject,其中projectId和userId两个外键。定义through选项后，Sequelize会尝试自动生成名字。
//在本例中，会为User添加方法getUsers,setUsers,addUser,addUsers到Project中。getProjects,setProjects,addProject,addProjects到User中.


let task_enrol_list = Task_enrol_list.sync();

module.exports = Task_enrol_list

